﻿using Microsoft.AspNetCore.Mvc;
using ZR.Admin.WebApi.Filters;
using ZR.Model.Dto.Business.ProductionControl;
using ZR.Model.Models.ProductionControl;
using ZR.Service.IService.ProductionControl;

//创建时间：2025-06-04
namespace ZR.Admin.WebApi.Controllers
{
    /// <summary>
    /// 工艺路线
    /// </summary>
    [Verify]
    [Route("business/CksTechnicalFlowNodes")]
    [ApiExplorerSettings(GroupName = "business")]
    public class CksTechnicalFlowNodesController : BaseController
    {
        /// <summary>
        /// 工艺路线接口
        /// </summary>
        private readonly ICksTechnicalFlowNodesService _CksTechnicalFlowNodesService;

        public CksTechnicalFlowNodesController(ICksTechnicalFlowNodesService CksTechnicalFlowNodesService)
        {
            _CksTechnicalFlowNodesService = CksTechnicalFlowNodesService;
        }

        /// <summary>
        /// 查询工艺路线列表
        /// </summary>
        /// <param name="parm"></param>
        /// <returns></returns>
        [HttpGet("list")]
        [ActionPermissionFilter(Permission = "ckstechnicalflownodes:list")]
        public IActionResult QueryCksTechnicalFlowNodes([FromQuery] CksTechnicalFlowNodesQueryDto parm)
        {
            var response = _CksTechnicalFlowNodesService.GetList(parm);
            return SUCCESS(response);
        }


        /// <summary>
        /// 查询工艺路线详情
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        [HttpGet("{Id}")]
        [ActionPermissionFilter(Permission = "ckstechnicalflownodes:query")]
        public IActionResult GetCksTechnicalFlowNodes(int Id)
        {
            var response = _CksTechnicalFlowNodesService.GetInfo(Id);

            var info = response.Adapt<CksTechnicalFlowNodesDto>();
            return SUCCESS(info);
        }

        /// <summary>
        /// 添加工艺路线
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        [ActionPermissionFilter(Permission = "ckstechnicalflownodes:add")]
        [Log(Title = "工艺路线", BusinessType = BusinessType.INSERT)]
        public IActionResult AddCksTechnicalFlowNodes([FromBody] CksTechnicalFlowNodesDto parm)
        {
            var modal = parm.Adapt<CksTechnicalFlowNodes>().ToCreate(HttpContext);

            var response = _CksTechnicalFlowNodesService.AddCksTechnicalFlowNodes(modal);

            return SUCCESS(response);
        }

        /// <summary>
        /// 更新工艺路线
        /// </summary>
        /// <returns></returns>
        [HttpPut]
        [ActionPermissionFilter(Permission = "ckstechnicalflownodes:edit")]
        [Log(Title = "工艺路线", BusinessType = BusinessType.UPDATE)]
        public IActionResult UpdateCksTechnicalFlowNodes([FromBody] CksTechnicalFlowNodesDto parm)
        {
            var modal = parm.Adapt<CksTechnicalFlowNodes>().ToUpdate(HttpContext);
            var response = _CksTechnicalFlowNodesService.UpdateCksTechnicalFlowNodes(modal);

            return ToResponse(response);
        }

        /// <summary>
        /// 删除工艺路线
        /// </summary>
        /// <returns></returns>
        [HttpDelete("delete/{ids}")]
        [ActionPermissionFilter(Permission = "ckstechnicalflownodes:delete")]
        [Log(Title = "工艺路线", BusinessType = BusinessType.DELETE)]
        public IActionResult DeleteCksTechnicalFlowNodes([FromRoute] string ids)
        {
            var idArr = Tools.SplitAndConvert<int>(ids);

            return ToResponse(_CksTechnicalFlowNodesService.Delete(idArr));
        }

    }
}